//
//  EFOrderPayQcodeCell.m
//  EnjogFood
//
//  Created by 王芳 on 17/5/11.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFOrderPayQcodeCell.h"
#import "EFOrderQCodeItem.h"

@interface EFOrderPayQcodeCell ()
@property (strong, nonatomic) UILabel *payTipLabel;
@property (strong, nonatomic) UIImageView *payQcodeImageV;
@property (strong, nonatomic) UILabel *codeNumLabel;
@property (strong, nonatomic) UIView *line;
@end

@implementation EFOrderPayQcodeCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

- (void)initUI{
    [self.contentView addSubview:self.payTipLabel];
    [self.contentView addSubview:self.payQcodeImageV];
    [self.contentView addSubview:self.codeNumLabel];
    [self.contentView addSubview:self.line];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.line.left = 20;
    self.line.bottom = self.height;
}

- (void)setObject:(EFOrderQCodeItem *)item{
    self.payTipLabel.left = 20;
    self.payTipLabel.top = 13;
    [self.payQcodeImageV setImageWithURL:[NSURL URLWithString:item.payment_qrcode]];
    self.payQcodeImageV.left = (kScreenWidth - self.payQcodeImageV.width)/2;
    self.payQcodeImageV.top = 34;
    self.codeNumLabel.text = [NSString stringWithFormat:@"编号%@",item.payment_no];
    [self.codeNumLabel sizeToFit];
    self.codeNumLabel.left = (kScreenWidth - self.codeNumLabel.width)/2;
    self.codeNumLabel.top = self.payQcodeImageV.bottom + 4;
}

- (UILabel *)payTipLabel{
    if (!_payTipLabel) {
        _payTipLabel = [[UILabel alloc] init];
        _payTipLabel.font = [UIFont systemFontOfSize:13];
        _payTipLabel.textColor = kBlack999;
        _payTipLabel.text = @"支付凭证：";
        [_payTipLabel sizeToFit];
    }
    return _payTipLabel;
}

- (UIImageView *)payQcodeImageV{
    if (!_payQcodeImageV) {
        _payQcodeImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
        _payQcodeImageV.backgroundColor = RGBCOLOR(0xf3f3f3);
    }
    return _payQcodeImageV;
}

- (UILabel *)codeNumLabel{
    if (!_codeNumLabel) {
        _codeNumLabel = [[UILabel alloc] init];
        _codeNumLabel.font = [UIFont systemFontOfSize:13];
        _codeNumLabel.textColor = kBlack333;
        _codeNumLabel.text = @"编号：2454254352435";
        [_codeNumLabel sizeToFit];
    }
    return _codeNumLabel;
}

- (UIView *)line{
    if (!_line) {
        _line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 2*20, 1)];
        _line.backgroundColor = RGBCOLOR(0xececec);
    }
    return _line;
}

@end
